<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

require_once APPPATH . 'third_party/alipay/alipay.config.php';
require_once APPPATH . 'third_party/alipay/alipay_submit.class.php';
require_once APPPATH . 'third_party/alipay/alipay_notify.class.php';

class Alipay {
	
	public function refund($data) {
		$parameter = array(
				"service" => "refund_fastpay_by_platform_pwd",
				"partner" => trim(AlipayConfig::partner),
				"notify_url"	=> base_url('notify.php'),
				"seller_email"	=> trim(AlipayConfig::seller_email),
				"refund_date"	=> date('Y-m-d H:i:s'),
				"batch_no"	=> $data['batch_no'],
				"batch_num"	=> $data['batch_num'],
				"detail_data"	=> $data['detail_data'],
				"_input_charset"	=> trim(strtolower(AlipayConfig::input_charset))
		);
		$alipaySubmit = new AlipaySubmit();
		return $alipaySubmit->buildRequestForm($parameter,"get", "确认");
	}
	
	public function alipayNotify() {
		//计算得出通知验证结果
		$alipayNotify = new AlipayNotify();
		$result = $alipayNotify->verifyNotify();
		return $result;
	}
}